---
title: Convert
description: Convert SQL migration files to a pgroll migration
---

## Command

```
$ pgroll convert /path/to/migration.sql
```

This reads the SQL statements from `/path/to/migration.sql` and translates them into a `pgroll` migration. The migration files are written to stdout in YAML format.

The optional `--json` flag can be used to write migration files in JSON.

### Read SQL statements from stdin

If a file name is not specified `pgroll convert` reads the SQL statements from stdin.

```
$ cat 'CREATE TABLE my_table(name text);' | pgroll convert
```

<Warning>
The generated pgroll migrations might include `up` and `down` migrations. Those must be filled in manually because currently `pgroll` is unable to infer correct up and down migrations.
</Warning>
